package com.lyn.chapter2.demo1;

public class RaceConditionDemo {
	public static void main(String[] args) {
		//我的电脑是双核，因此这里创建两个线程
		//动态获取CPU个数
		//int numberOfThreads = Runtime.getRuntime().availableProcessors();
		int numberOfThreads = 4;
		Thread[] workerThreads = new Thread[numberOfThreads];
		for(int i=0; i<numberOfThreads; i++) {
			//10表示每个线程处理10个请求。如果是双核，则一共产生20个随机数
			workerThreads[i] = new WorkerThread(i, 10);
		}
		
		//所有线程创建完毕后，一次性启动他们
		for(Thread thread : workerThreads) {
			thread.start();
		}
	}
}
